<title>话题管理</title>
  
<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">主页</a>
    <a><cite>问答管理</cite></a>
    <a><cite>话题管理</cite></a>
  </div>
</div>


<div class="layui-fluid">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
  <div class="layui-card">
   <div class="layui-card-header">话题管理</div>
    <div class="layui-card-body">
    
      <div style="padding-bottom: 10px;">
        <a href="#J_view" class="layui-btn J_popup" title="添加话题"><i class="layui-icon layui-icon-add-circle"></i>添加</a>
        <a href="wendasns/topic/remove" class="layui-btn J_req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
      </div>
      
      <table id="J_table_list" lay-filter="J_table_list" url="{:url('wendasns/topic/edit')}"></table>
    </div>
    
  </div>
</div>
  </div>
</div>

<script type="text/html" id="J_table_tool">
  <a href="#J_view" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="popup" title="编辑话题"><i class="layui-icon layui-icon-edit"></i>编辑</a>
  <a href="wendasns/topic/remove" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
</script>
      
<script>
;!function(){
  var $ = layui.$
  ,admin = layui.admin
  ,table = layui.table
  ,router = layui.router()
  ,upload = layui.upload
  ,form = layui.form;
  
  //执行渲染
table.render({
  elem: '#J_table_list'
  ,url: '{:url('wendasns/topic/list')}'
  ,cols: [[
      {type: 'checkbox',fixed:'left'}
      ,{field:'id',title:'ID',align:'center',width:100}
      ,{field:'name',title:'话题',minWidth:200,edit:'text'}
      ,{field:'alias',title:'别名',minWidth:200,edit:'text'}
      ,{field:'icon',title:'图标',align:'center',width:80,templet:'<div><i class="layui-icon {{d.icon}}"></i></div>'}
      ,{title:'操作',width:150,align:'center',toolbar:'#J_table_tool'}
  ]]
  ,page: true
  ,limit: 20
  ,height: 'auto'
  ,text: {
    none: '暂无数据！'
  }
});

  form.on('select(select_type)', function(obj){
    $('.type_all').hide();
    $('.type_'+obj.value).show();
  });

}();
</script>
<script>
  function topicimgup(){
	layui.upload.render({
      elem: '.J_topic_img'
      ,url: '{:url('wendasns/topic/upload')}'
      ,done: function(res){
      	layer.msg(res.msg);
        layui.$('.topic_image').val(res.data.src);
        layui.$('.imgtag').attr('src', res.data.src);
      }
      ,error: function(){
        layer.msg('上传失败');
      }
    });  
}
</script>

<script type="text/html" id="J_view" lay-done="topicimgup()">
  <form class="layui-form" action="{:url('wendasns/topic/edit')}" method="post">
    <input type="hidden" name="id" value="{{d.id||0}}">
    
            <div class="layui-form-item type_all type_2">
              <label class="layui-form-label">话题</label>
              <div class="layui-input-inline">
                <input type="text" name="name" value="{{d.name||''}}" lay-verify="required" class="layui-input">
              </div>
            </div>
            
            <div class="layui-form-item">
              <label class="layui-form-label">别名</label>
              <div class="layui-input-inline">
                <input type="text" name="alias" value="{{d.alias||''}}" lay-verify="required" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">必须是英文字母<br>如不填写，系统自动转拼音</div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label">话题介绍</label>
              <div class="layui-input-block">
                <textarea placeholder="介绍一下话题嘛" name="intro" class="layui-textarea">{{d.intro||''}}</textarea>
              </div>
              </div>

            <div class="layui-form-item">
              <label class="layui-form-label">图标</label>
              <div class="layui-input-inline" style="width: 390px;">
                  <input name="icon" placeholder="图片地址" value="{{d.icon||''}}" autocomplete="off" class="layui-input topic_image">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label"></label>
              <div class="layui-input-inline">
                <img src="{{d.icon||''}}" class="imgtag" width="100%"/>
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <a href="javascript:;" class="layui-btn layui-btn-primary J_topic_img"><i class="layui-icon layui-icon-upload-drag"></i>上传照片</a>
                  <br>图片大小建议 80x80<br>支持格式'jpg','jpeg','gif','png'
              </div> 
              </div>
            </div>
            
            <div class="layui-form-item">
              <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="J_ajax_submit_btn"><i class="layui-icon layui-icon-ok-circle"></i>提交</button>
              </div>
            </div>
          </form>
</script>